<template>
  <div>
    <ul>
      <li v-for="item in arr" :key="item">
        <input type="checkbox" name="" id="" :value="item" v-model="newArr" />
        <span>{{ item }}</span>
      </li>
    </ul>
    <p>你选中的元素累计和为：{{ numAll }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      newArr: [],
    };
  },
  computed: {
    numAll() {
      return this.newArr.reduce((num, item) => (num += item), 0);
    },
  },
};
</script>

<style>
</style>